
'''
file1 = open('/Users/kenblock/Desktop/Python练习/fightgame2.0.py','r',encoding='utf-8')
filecontext = file1.read()
print(filecontext)
file1.close()

file1 = open('/Users/kenblock/Desktop/Python练习/fightgame2.0.py','a',encoding='utf-8')
file1.write('hello world')
filecontext = file1.read()
print(filecontext)
file1.close()


file2 = open('/Users/kenblock/Desktop/Python练习/abc.txt','w',encoding='utf-8')

file2.write('aaaaaaaaaaa\n')

file2.close()

with open('/Users/kenblock/Desktop/Python练习/abc.txt','a') as file2:

    file2.write('hahaha')

    '''

file3 = open('/Users/kenblock/Desktop/Python练习/abc.txt','r',encoding='utf-8')

scores = file3.readlines()

file3.close()


scores_list = []

for i in scores:
    data = i.split()
    sum = 0
    for j in data[1:]:
        sum += int(j)
    result = data[0] + str(sum)
    scores_list.append(result)

winner = open('/Users/kenblock/Desktop/Python练习/abc.txt','a',encoding='utf-8')

winner.writelines(scores_list)

winner.close()

